package com.lovoerp.util;

import java.sql.*;

public class DBHelper {
    public static final String DRIVER="com.mysql.cj.jdbc.Driver";
    //数据库ip
    public static final String URL="jdbc:mysql://47.99.48.28:3307/LovoERP";
    //数据库userid
    public static final String USER="root";
    //数据库密码
    public static final String PASSWORD="123456";
    static{
        try {
            Class.forName(DRIVER);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    public static Connection getConnection(){
        try {
            Connection conn= DriverManager.getConnection(URL,USER,PASSWORD);
            return conn;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static void close(ResultSet rs, Statement stmt, Connection conn){
        try {
            if (rs!=null){
                rs.close();
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            stmt.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
